import { Pipe, PipeTransform } from '@angular/core';

@Pipe({
  // 定义引用管道名
  name: 'mydemo'
})
export class MydemoPipe implements PipeTransform {

  // transform(value: unknown, ...args: unknown[]): unknown {
  //   return null;
  // }
  // 自定义管道函数(函数名固定为transform)
  transform(value: string): string {
    if(!value) return value;
    if(typeof value !== 'string') {
      throw new Error('Invalid pipe argument for WelcomePipe');
    }
    return "Welcome to " + value;
  }

}
